<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script type="text/javascript">


var monthtext=['01','02','03','04','05','06','07','08','09','10','11','12'];

function populatedropdown(dayfield, monthfield, yearfield){
var today=new Date()
var dayfield=document.getElementById(dayfield)
var monthfield=document.getElementById(monthfield)
var yearfield=document.getElementById(yearfield)
for (var i=1; i<=31; i++)
dayfield.options[i]=new Option(i, i+1)
dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
for (var m=0; m<12; m++)
monthfield.options[m]=new Option(monthtext[m], monthtext[m])
monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
var thisyear=today.getFullYear()
for (var y=0; y<20; y++){
yearfield.options[y]=new Option(thisyear, thisyear)
thisyear+=1
}
yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Create Event</title>
<style type="text/css">
body {
	background-color: #FFE4E1;
}

h1 {
	color: #800000;
	text-align: center;
}
</style>
<script type="text/javascript">
function validateForm()
{
	var validformat=/^\d{2}\/\d{2}\/\d{4}$/; //Basic check for format validity
	 var returnval=false;
	var valid=true;
	 var numericExpression = /^[0-9]+$/;
    if(document.myForm.eventId.value=="")
    {
    	valid=false;
    	alert("EventId shouldnot be left blank");
    }
    else if(document.myForm.eventName.value=="")
    {
    	valid=false;
    	alert("eventName shouldnot be left blank");
    }
    else if(document.myForm.classSize.value=="")
    {
    	valid=false;
    	alert("classSize shouldnot be left blank");
    }
    else if(isNaN(myForm.classSize.value)) 
    { 
    	valid=false;
        alert("Invalid data format.\n\nOnly numbers are allowed."); 
         
      }
    else if(document.myForm.fees.value=="")
    {
    	valid=false;
    	alert("Fees shouldnot be left blank");
    }
    else if(isNaN(myForm.fees.value)) 
    { 
    	valid=false;
        alert("Invalid data format.\n\nOnly numbers are allowed."); 
         
      }
    else if(document.myForm.locationId.value=="")
    {
    	valid=false;
    	alert("Select Location");
    }
    else if(document.myForm.speakerName.value=="")
    {
    	valid=false;
    	alert("Select Speaker");
    }
    else if(document.myForm.promotion.value=="")
    {
    	valid=false;
    	alert("Select promotion");
    }
     else{
    	alert("form validated..");
    	window.location.href="/Events/GetPromotion";
    }
    return valid;
}

</script>
</head>
<body>
<%@include file="Page.jsp" %>

	<%@include file="header.jsp"%>
   
   <form name="Promotion" action="/EventManagementSystem/GetPromotion" onsubmit="return validateForm()">
         <h1>Promotion</h1>
        <table border="1" align="center">
            <tr>
                <td>Enter Promotion Id :</td>
                <td><input type="text" name="PromotionId" /></td>
            </tr>
            <tr>
                <td>Enter Promotion Code :</td>
                <td><input type="text" name="PromotionCode"/></td>
            </tr>
            <tr>
				<td>Enter Start Date :</td>
				<td><select name="day">
				</select> <select name="month">
				</select> <select name="year">
				</select></td>

			</tr>
			<tr>
				<td>Enter End Date :</td>
				<td><select name="day1">
				</select> <select name="month1">
				</select> <select name="year1">

				</select></td>



			</tr>
                <td>Enter Discount :</td>
                <td><input type="text" name="Discount"/></td>
            </tr>
            
            <tr>
               <td align="right"><input type="submit" value="submit" /></td>
               <td><input type="reset"/><input type="button" value="Cancel" onClick=""/></td>
            </tr>
        </table>
        
        
        
   </form>
   <script type="text/javascript">
//populatedropdown(id_of_day_select, id_of_month_select, id_of_year_select)
window.onload=function(){
populatedropdown("day", "month", "year")
populatedropdown("day1", "month1", "year1")
}

</script>
<%@include file="Footer.jsp"%>
   
</body>
</html>